<script language="JavaScript">
$.post('{{ urlfor "RetailController.DailyReport" }}', function (res) {
    if(res.code == 0) {
        var data = res.data;
        //营业
        dobusiness(data.dobusiness);
        //销售
        sale(data.sale);
        //支付方式
        paytype(data.paytype);
        //销售人员
        salepeople(data.salepeople);
        //验光师
        optometrist(data.optometrist);
    }
}, 'json');

var dobusiness = function (b) {
    var html = [];
    html.push('<li>营业金额<span class="value" style="font-weight: bold">￥'+ b['营业金额'] +'</span></li>');
    html.push('<li>销售金额<span class="value">￥'+ b['销售金额'] +'</span></li>');
    html.push('<li>退货金额<span class="value am-text-success">￥'+ b['退货金额'] +'</span></li>');
    html.push('<li>待付金额<span class="value am-text-warning">￥'+ b['待付金额'] +'</span></li>');
    $('#daily_price_info').find('ul').html(html.join(''));
};
var sale = function (b) {
    var html = [];
    html.push('<li>销售单金额<span class="value" style="font-weight: bold">￥'+ b['销售单金额'] +'</span></li>');
    html.push('<li>成交单数<span class="value">'+ b['成交单数'] +'</span></li>');
    html.push('<li>退货金额<span class="value am-text-success">￥'+ b['退货金额'] +'</span></li>');
    html.push('<li>退货单数<span class="value am-text-warning">'+ b['退货单数'] +'</span></li>');
    html.push('<li>优惠金额<span class="value">￥'+ b['优惠金额'] +'</span></li>');
    $('#sales_info').find('ul').html(html.join(''));
};
var paytype = function (b) {
    var html = [];
    html.push('<li>现金<span class="value am-text-primary">￥'+ b['现金'] +'</span></li>');
    html.push('<li>支付宝<span class="value">'+ b['支付宝'] +'</span></li>');
    html.push('<li>微信<span class="value am-text-success">￥'+ b['微信'] +'</span></li>');
    html.push('<li>刷卡<span class="value am-text-warning">'+ b['刷卡'] +'</span></li>');
    $('#pay_type_info').find('ul').html(html.join(''));
};
var salepeople = function (b) {
    var html = [];
    $.each(b, function (idx, value) {
        html.push('<li>'+ idx +'<span class="value">￥'+ value +'</span></li>');
    });
    $('#sales_person_ranking').find('ul').html(html.join(''));
};

var optometrist = function (b) {
    var html = [];
    $.each(b, function (idx, value) {
        html.push('<li>'+ idx +'<span class="value">￥'+ value +'</span></li>');
    });
    $('#optometry_person_ranking').find('ul').html(html.join(''));
};

</script>